package com.changgou.order.listener;

import com.alibaba.fastjson.JSON;
import com.changgou.order.config.RabbitMQConfig;
import com.changgou.order.service.OrderService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
public class OrderPayListener {

    @Autowired
    private OrderService orderService;

    @RabbitListener(queues = "order_pay")
    public void receivePayMessage(String message){
        System.out.println("接收到的消息："+message);
        Map map= JSON.parseObject(message,Map.class);
        orderService.updatePayStatus(map.get("orderId").toString(),map.get("transactionId").toString());
    }
}
